package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelAddDto;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.entity.NursingPlan;
import com.zzyl.service.HulidengjiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级")
public class HulidengjiController {

    @Autowired
    private HulidengjiService hulidengjiService;

    @ApiOperation("护理等级查询")
    @GetMapping("/listAll")
    public ResponseResult<PageResponse<NursingLevel>> listAll(NursingLevelDto dto) {

        //  {"executeCycle":"1","executeTime":"2024-06-0"}
        PageResponse<NursingLevel> pageResponse = hulidengjiService.listAll(dto);
        return ResponseResult.success(pageResponse);

    }

    /*
     * 新增
     * */
    @ApiOperation("新增护理等级")
    @PostMapping("/insert")
    public ResponseResult insert( NursingLevelAddDto dto) {
        hulidengjiService.insert(dto);
        return ResponseResult.success();
    }

    /*
     * search 2.3 条件分页查询
     * */
    @ApiOperation("条件分页查询")
    @GetMapping("/search")
    public ResponseResult<PageResponse<NursingLevel>> search(NursingLevelDto dto) {
        PageResponse<NursingLevel> page = hulidengjiService.search(dto);
        return ResponseResult.success(page);
    }

    /*
     * 3.4 根据id查询
     * */
    @ApiOperation("根据id查询")
    @GetMapping("{id}")
    public ResponseResult<NursingLevel> getById(@PathVariable("id") Long id) {
        NursingLevel vo = hulidengjiService.getById(id);
        return ResponseResult.success(vo);
    }

    /*
     * 3.5 修改
     * */
    @ApiOperation("修改")
    @PutMapping("/update")
    /**
     * 更新
     * @param dto 更新参数
     * @return 返回成功标志
     */
  public ResponseResult<NursingLevel> update(@RequestBody NursingLevelAddDto dto) {
        hulidengjiService.update(dto);
        return ResponseResult.success();
    }

    /*
     * 3.6 删除
     * */

    @ApiOperation("删除")
    @DeleteMapping("{id}")
   // 根据路径变量id删除护理等级
 public ResponseResult<NursingLevel> delete(@PathVariable("id") Long id) {
        // 调用服务层删除方法
        hulidengjiService.delete(id);
        // 返回成功响应
        return ResponseResult.success();
    }
       /*
       * 启用禁用
      * */
    @ApiOperation("启用禁用")
    @PutMapping("{id}/status/{status}")
    public ResponseResult updateStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status) {
       // 调用服务层的方法，更新状态
     hulidengjiService.updateStatus(id, status);
   // 返回成功响应
     return ResponseResult.success();

        }



    }